#!/bin/bash
cd ~/app-root/data/temp/Nexus4
url=$(curl -s https://dl.twrp.me/mako/ |grep -o "https:\//dl.twrp.me\/mako/twrp-[0-9][\.\-][0-9][\.\-][0-9][\.\-][0-9]-mako.img.html" |sed '2,$d')
if ! (grep -q $url twrpurl); then
echo $url > twrpurl
curl $(sed s#.html## twrpurl) -H "Referer: $url" -o recovery.img
mv -f recovery.img ~/app-root/data/twrp-mako-zip/recovery.img
cd $OPENSHIFT_DATA_DIR/twrp-mako-zip/
git add --all
git commit -m "$(grep -o "twrp-.*mako" ~/app-root/data/temp/Nexus4/twrpurl)"
git push -u origin master
fi
